package org.dtrd.modules.record.entity.bean;

import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.dtrd.common.util.DateUtils;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.record.entity.po.DtrdEntRdSigninFoodRecord;
import org.dtrd.modules.suggest.entity.bean.SigninRecordSuggestListInfo;

import java.util.Date;
import java.util.List;

@ApiModel("饮食记录对象")
@Data
public class DietRecordBean {

	@ApiModelProperty("记录id")
	private Integer id;

	@ApiModelProperty(value = "患者id", required = true)
	private Integer patientId;

	@ApiModelProperty(value = "记录类型: 1-早餐,2-午餐,3-晚餐,4-早餐加餐,5-午餐加餐,6-晚餐加餐",example = "1 (表示早餐)", required = true)
	private Integer foodRecordType;

	@ApiModelProperty(value = "记录日期 yyyy-MM-dd HH:mm:ss", example = "2021-10-15 22:19:57", required = true)
	private String recordTime;

	@ApiModelProperty(value = "饮食记录名称")
	private String name;

	@ApiModelProperty(value = "饮食记录图片, 上传图片的链接", required = true)
	private String recordPhoto;

	@ApiModelProperty(value = "饮食描述")
	private String foodRecordDesc;

	@ApiModelProperty(value = "备注, 建议添加到备注里")
	private String foodRecordRemark;

	@ApiModelProperty(value = "建档标记 1-建档, 0-日常检测")
	private Integer foodRecordArchiveTag;

	@ApiModelProperty(value = "评分建议")
	private List<SigninRecordSuggestListInfo> signinRecordSuggestListInfo;

	public DietRecordBean(){}

	public DietRecordBean(Integer patientId, Constant.FoodRecordType type, Date date, String photo){
		this.patientId = patientId;
		this.foodRecordType = type.getType();
		this.recordTime = DateUtils.formatDate(date, DateUtils.datetimeFormat.get().toPattern());
		this.recordPhoto = photo;
	}

	public DietRecordBean parseFromPo(DtrdEntRdSigninFoodRecord foodRecord){
		this.setId(foodRecord.getDataId());
		this.setPatientId(foodRecord.getPatientId());
		this.setFoodRecordType(foodRecord.getFoodRecordType());
		if (foodRecord.getRecordTime() != null) {
			this.setRecordTime(DateUtils.formatDate(foodRecord.getRecordTime(), DateUtils.datetimeFormat.get().toPattern()));
		}
		this.setRecordPhoto(foodRecord.getRecordPhoto());
		this.setFoodRecordRemark(foodRecord.getFoodRecordRemark());
		this.setFoodRecordArchiveTag(foodRecord.getFoodRecordArchiveTag());
		this.setFoodRecordDesc(foodRecord.getFoodRecordDesc());
		return this;
	}
}
